package com.bw.goods_module.detail;

import com.bw.common.mvvm.model.BaseRespository;
import com.bw.goods_module.home.HomeEntity;
import com.bw.network_sdk.BaseEntity;
import com.bw.network_sdk.HttpType;
import com.bw.network_sdk.NetWorkFactory;

import java.util.Map;

import io.reactivex.Observable;

public class GoodsDetailRespository extends BaseRespository {

    //获取商品详情
    private Observable<BaseEntity>requestDetails(Map<String,Object>map){
        Observable<GoodsDetailEntity>goodsDetailEntityObservable =
                NetWorkFactory.factory(HttpType.TOKENSIGN)
                        .create(ApiService.class)
                        .requestGoodsDetail(createBody(map));
        return checkNetWork(goodsDetailEntityObservable);
    }
    //获取推荐商品
    private Observable<BaseEntity>requestGoods(Map<String,Object>map){
        Observable<HomeEntity>homeEntityObservable =
                NetWorkFactory.factory(HttpType.TOKENSIGN)
                        .create(ApiService.class)
                        .requestGoodsList(createBody(map));
        return checkNetWork(homeEntityObservable);
    }
    //获取全部界面数据
    public Observable<BaseEntity>request(Map<String,Object>detail,Map<String,Object>goods){
        return mergeObservable(requestDetails(detail),requestGoods(goods));
    }
}
